-- hit_offset
-- created by wangy
-- 魔法值大于%消耗1点魔法抵消x点伤害

return {
    apply = function(prop, baseValue)
        return baseValue - prop[3];
    end,

    -- 攻击时触发
    trigger = function(who, prop, arg)
        local maxMp = who:getMaxMp();
        local mp = who:getMp();
        local rate = mp / maxMp * 1000;
        local rate2 = tonumber(prop[2]);

        -- 概率没发生
        if rate < rate2 then
            return false;
        end

        -- 消耗魔法值
        ME.user:costAttrib("mp", 1);

        return true;
    end,

    record = function(target, prop, path)
        return false;
    end
};